package site.jlopen.entity;

import org.secretflow.v1alpha1.constant.KusciaConstants;

import site.jlopen.kuscia.entity.GrpcApiInfo;

public class KusciaApiInfo extends GrpcApiInfo {
	private String address;
	private String tokenFile;
	private String protocol;
	private KusciaApiInfoTls tls;

	public KusciaApiInfo(String protocol, String address) {
		super();
		this.protocol = protocol;
		this.address = address;
	}

	public KusciaApiInfo ext(String tokenFile, String certFile, String keyFile, String caFile) {
		if (!KusciaConstants.KUSCIA_PROTOCOL_NOTLS.equals(this.getProtocol())) {
			this.tls = new KusciaApiInfoTls();
			KusciaApiInfoTls tls = new KusciaApiInfoTls(certFile, keyFile, caFile);
			this.tokenFile = tokenFile;
			this.tls = tls;
		}
		return this;
	}

	public class KusciaApiInfoTls extends GrpcApiInfoTls {
		private String certFile;
		private String keyFile;
		private String caFile;

		public KusciaApiInfoTls() {
			super();
		}

		public KusciaApiInfoTls(String certFile, String keyFile, String caFile) {
			super();
			this.certFile = certFile;
			this.keyFile = keyFile;
			this.caFile = caFile;
		}

		@Override
		public String getCertFile() {
			return this.certFile;
		}

		@Override
		public String getKeyFile() {
			return this.keyFile;
		}

		@Override
		public String getCaFile() {
			return this.caFile;
		}

	}

	@Override
	public String getAddress() {
		return this.address;
	}

	@Override
	public String getTokenFile() {
		return this.tokenFile;
	}

	@Override
	public String getProtocol() {
		return this.protocol;
	}

	@Override
	public KusciaApiInfoTls getTls() {
		return this.tls;
	}

}
